import {createStore} from 'vuex'

// 引入模块
import moduleA from './modules/moduleA.js'
import moduleB from './modules/moduleB.js'

// 创建一个vuex的store实例对象
const store = createStore({
    modules:{
        a: moduleA,
        b: moduleB
    },
    state(){
        return {
            count: 10,
        }
    },
    getters:{
        tenTimes:(state)=>{
            return state.count * 10
        }
    },
    mutations:{
        increment(state, playload){
            state.count = playload.count
        }
    },
    actions:{
        asyncIncrement(context, playload){
            console.log('context',context);
            context.commit("increment", playload)
        }
    }
})

export default store